package za.org.jcicada.comms.impl.stub;

import java.io.IOException;

import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IConnector;
import za.org.jcicada.comms.exceptions.CommsException;

public class StubConnector implements IConnector {
    
    private StubAcceptor acceptor;
    
    public StubConnector(StubAcceptor acceptor) {
        if (acceptor == null) {
            throw new IllegalArgumentException("Acceptor can't be null");
        }
        this.acceptor = acceptor;
    }

    public void close() throws CommsException {
        // not shutdown required
    }

    public IConnection connect() throws IOException {
        StubConnection queue = new StubConnection();
        acceptor.connect(queue);
        return queue;
    }
    
}
